/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
//import javax.validation.constraints.NotNull;
//import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author The Lunatics
 */
@Entity
@Table(name = "accounts")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Accounts.findAll", query = "SELECT a FROM Accounts a"),
    @NamedQuery(name = "Accounts.findByAccountNumber", query = "SELECT a FROM Accounts a WHERE a.accountNumber = :accountNumber"),
    @NamedQuery(name = "Accounts.findByAccountCreationDate", query = "SELECT a FROM Accounts a WHERE a.accountCreationDate = :accountCreationDate"),
    @NamedQuery(name = "Accounts.findByCreditCardNumber", query = "SELECT a FROM Accounts a WHERE a.creditCardNumber = :creditCardNumber"),
    @NamedQuery(name = "Accounts.findByStatus", query = "SELECT a FROM Accounts a WHERE a.status = :status")})
public class Accounts implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    //@NotNull
    @Column(name = "Account_Number")
    private Integer accountNumber;
    @Basic(optional = false)
    //@NotNull
    @Column(name = "Account_Creation_Date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date accountCreationDate;
    //@Size(max = 17)
    @Column(name = "Credit_Card_Number")
    private String creditCardNumber;
    //@Size(max = 10)
    @Column(name = "Status")
    private String status;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "accounts")
    private Collection<UserHasAccount> userHasAccountCollection;

    public Accounts() {
    }

    public Accounts(Integer accountNumber) {
        this.accountNumber = accountNumber;
    }

    public Accounts(Integer accountNumber, Date accountCreationDate) {
        this.accountNumber = accountNumber;
        this.accountCreationDate = accountCreationDate;
    }

    public Integer getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(Integer accountNumber) {
        this.accountNumber = accountNumber;
    }

    public Date getAccountCreationDate() {
        return accountCreationDate;
    }

    public void setAccountCreationDate(Date accountCreationDate) {
        this.accountCreationDate = accountCreationDate;
    }

    public String getCreditCardNumber() {
        return creditCardNumber;
    }

    public void setCreditCardNumber(String creditCardNumber) {
        this.creditCardNumber = creditCardNumber;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @XmlTransient
    public Collection<UserHasAccount> getUserHasAccountCollection() {
        return userHasAccountCollection;
    }

    public void setUserHasAccountCollection(Collection<UserHasAccount> userHasAccountCollection) {
        this.userHasAccountCollection = userHasAccountCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accountNumber != null ? accountNumber.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Accounts)) {
            return false;
        }
        Accounts other = (Accounts) object;
        if ((this.accountNumber == null && other.accountNumber != null) || (this.accountNumber != null && !this.accountNumber.equals(other.accountNumber))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Accounts[ accountNumber=" + accountNumber + " ]";
    }
    
}
